import { axios } from "@/utils/request";

// 预约服务人员
export const bookServicePerson = (params: { customerId: number; servicePersonId: number; serviceId: number }) => {
  return axios({
    url: "/orders/add",
    method: "post",
    data: params,
  });
};
// 记录浏览顾客浏览
export const customerbrowse = (params: { customerId: number; personId: number }) => {
  return axios({
    url: "/history/view/person",
    method: "post",
    data: {
      customerId: params.customerId,
      personId: params.personId,
    },
  });
};
// 发布需求
export const postDemand = (data: {
  customerId: number;
  description: string;
  location: string;
  serviceStartTime: string;
  type: string;
}) => {
  return axios({
    url: "/customer-demand/publish",
    method: "post",
    data: data,
  });
};

// 删除需求
export const deletedemand = (params: { demandId: number }) => {
  return axios({
    url: `/customer-demand/${params.demandId}`,
    method: "delete",
  });
};

// 编辑个人信息
export const updateCustomerInfo = (params: {
  id: number;
  name: string;
  email: string;
  phone: string;
  address: string;
}) => {
  return axios({
    url: `/customers/${params.id}`,
    method: "put",
    data: params,
  });
};

// 获取订单
export const getCustomerOrders = (customerId: number) => {
  return axios({
    url: `/orders/customer/${customerId}`,
    method: "get",
  });
};

// 取消订单
export const cancelOrder = (id: number) => {
  return axios({
    url: `/orders/biz/${id}`,
    method: "delete",
  });
};

//获取该客户发布的需求
export const getCustomerDemand = (customerId: number) => {
  return axios({
    url: `/customer-demand/by-customer/${customerId}`,
    method: "get",
  });
};

// 历史浏览
export const getCustomerHistory = (customerId: number) => {
  return axios({
    url: `/history/person/${customerId}`,
    method: "get",
  });
};

// 获取订单详情
export const getOrderDetail = (orderId: number) => {
  return axios({
    url: `/orders/biz/detail/${orderId}`,
    method: "get",
  });
};

// 提交评价
export const submitEvaluation = (data: { businessOrderId: number; rating: number; content: string }) => {
  return axios({
    url: `/reviews/order/${data.businessOrderId}`,
    method: "post",
    data,
  });
};

// 获取历史投诉
export const getcusComplaintHistory = (customerId: number) => {
  return axios({
    url: `/complaints/by-customer/${customerId}`,
    method: "get",
  });
};

// 提交投诉
export const submitComplaint = (data: { businessOrderId: number; customerId: string; complaintContent: string }) => {
  return axios({
    url: "/complaints/submit",
    method: "post",
    data: {
      businessOrderId: data.businessOrderId,
      customerId: data.customerId,
      complaintContent: data.complaintContent,
    },
  });
};
//与服务人员聊天
export const creatroom = (data: { customerId: number; servicePersonId: number }) => {
  return axios({
    url: "/chat/create-room?customerId=" + data.customerId + "&servicePersonId=" + data.servicePersonId,
    method: "get",
  });
};
